<?php
/** $Id: default_form.php 11917 2009-05-29 19:37:05Z ian $ */
	defined( '_JEXEC' ) or die( 'Restricted access' );
	$session = JFactory::getSession();
	$app = JFactory::getApplication();
	$template = JURI::base() . 'templates/' . $app->getTemplate();
?>
<div id="header">
  <div id="w-header">
    <div class="logo"><a href="index.php">Forside</a> </div>
    <!--.logo-->
     {module login menu}    
    <!--.nav-top-1-->
    <div class="clear"></div>
    <div class="main-nav">
      {module main menu}
    </div>
    <!--.main-nav-->
    <div class="clear"></div>
  </div>
  <!--#w-header--> 
</div>
<!--#header-->

<div id="main">
  <div id="w-main">
    <div id="main-left">
	<div class="left-find"></div>
	<div class="right-find"></div>
		<div class="find">
			{module search}
		</div> 
      <!--.find-->
      <div class="clear"></div>
      <div class="infomation">
		<?php $article = JUtility::getArticle(15); ?>
        <h2><a href="#"><?php echo $article->title; ?></a></h2>
        <?php echo $article->introtext; ?>
      </div>
      <!--.infomation--> 
    </div>
    <!--#main-left-->
  <div id="main-right2">
      <div id="edit-account-page">
       	<div class="edit-account-content">	
        	<div class="infohide">
       		<?php
			 $article = JUtility::getArticle(10);
			 echo $article->introtext;
			 ?>
             </div>
            <form class="f-create-order" name="f-create-order" id="f-create-order" action="" method="get">
            	<fieldset>
                	<div class="infohide">
                	<div>
                    	<label>BEGIVENHED:</label><br>
                        <!--<input id="name" name="name" type="text" value="<?php if(isset($this->item_user->title)) echo $this->item_user->title;?>">-->
                        <select id="name" name="name" >
                        	<?php 
							$name_cat = $this->data->getCategorys('com_begivenhedcates');
							
							for($i=0;$i<count($name_cat);$i++) {
							?>
                            	<option <?php if (isset($this->item_user->title)&&$this->item_user->title == $name_cat[$i]->title) echo 'selected="selected" ';?> value="<?php echo $name_cat[$i]->title;?>"><?php echo $name_cat[$i]->title;?></option>
                            <?php
							}
							?>
                        	
                        </select>
                    </div>
                    <div>
                    	<label>ANTAL GÆSTER:</label><br>
                        <input id="quantity" name="quantity" type="text" value="<?php if(isset($this->item_user->title)) echo $this->item_user->guests;?>">
                    </div>
					<div>
                    	<label>ADRESSE:</label><br>
                        <input id="address" name="address" type="text" value="<?php if(isset($this->item_user->title)) echo $this->item_user->address;?>">
                    </div> 	
                    <div class="w88">
                    	<label>POST NR: </label><br>
                        <input id="postcode" name="postcode" class="w88" type="text" maxlength="4" value="<?php if(isset($this->item_user->title)) echo $this->item_user->postcode;?>">
                    </div>
                    <div class="w260">
                    	<label>BY:</label><br>
                        <input id="city" name="city" class="w260" type="text" value="<?php if(isset($this->item_user->title)) echo $this->item_user->city;?>">
                    </div>
                    <div >
                    	<label>DATO &amp; TIDSPUNKT:</label><br>
                        <input id="datepicker2" name="datepicker2" style="background: url(<?php echo $template; ?>/images/bg-input-datapicker2.png) no-repeat right; cursor:pointer;" type="text" value="<?php if(isset($this->item_user->title)) echo  JFactory::getDate($this->item_user->deadline)->toFormat('%Y-%m-%d'); ?>">
                    </div>
                    <div >
                      <label>Start tidspunkt</label><br>
                      <select class="w174 " id="start_hour" name="start_hour" >
                      	<?php
							 for($i=1;$i<24;$i++) {
								 ?>
                                 <option <?php if (isset($this->item_user)&&$this->item_user->start_hour == $i) echo 'selected="selected" ';?> value="<?php echo $i;?>"><?php echo $i;?></option>
                                 <?php
							 }
						?>
                      </select>
                      <select class="w174" id="start_minute" name="start_minute">
                       	<?php
							 for($i=0;$i<60;$i+=15) {
								 ?>
                                 <option <?php if (isset($this->item_user)&&$this->item_user->start_minute == $i) echo 'selected="selected" ';?> value="<?php echo $i;?>"><?php echo $i;?></option>
                                 <?php
							 }
						?>
                      </select>
                    </div>
                    <div>
                      <label>Tilbud ønskes på</label><br>
                      <select id="offer" name="offer">
                        	<?php 
							$offerscates = $this->data->getCategorys('com_offerscates');
							for($i=0;$i<count($offerscates);$i++) {
							?>
                            	<option <?php if (isset($this->item_user)&&$this->item_user->offer == $offerscates[$i]->id) echo 'selected="selected" ';?> value="<?php echo $offerscates[$i]->id;?>"><?php echo $offerscates[$i]->title;?></option>
                            <?php
							}
							?>
                      </select>
                    </div>
                    <div style="clear:both;">
                    	<label>TILKNYT KOMMENTAR:</label><br>
                        <textarea id="description" name="description" cols="" rows=""><?php if(isset($this->item_user->title)) echo $this->item_user->description;?></textarea>
                    </div>
                    <div>
                    	<input class="cb" id="agree" name="agree" type="checkbox" value="">
                        <span>
                        
                        <a target="_blank" href="<?php echo JRoute::_('index.php?option=com_jobs&view=handelsbetingelser');?>">Jeg accepterer handelsbetingelser</a>
                        </span>
                    </div>
                    <div class="clear"></div>
                  <div class="bnt-create-order">
                    	<a href="#" onclick="jQuery('#f-create-order').submit();" >Opret ordre</a>                                                
                    </div><!--.bnt-create-order-->
                    <input type="hidden" name="option" value="com_jobs" />
                    <input type="hidden" value="0" name="allowsubmit" id="allowsubmit"/>
                    <input type="hidden" name="id" value="<?php echo JRequest::getVar('id');?>" />
					<input type="hidden" name="task" value="<?php if(JRequest::getVar('task')=='edit'){ echo 'editTilmelding';} else {echo 'createNew';}?>" />
					<?php echo JHtml::_('form.token'); ?>
                   </div>
                   
                   <div class="request-offer" style="clear:both;">
      		<div class="catering noDisplay">
                	<h2>Indhent tilbud på Catering</h2>
                  <h3>Detaljer</h3>
                  <div class="request-content ">
                    <label>Ønsket mad:</label>
                   
                    		<?php 
							//$food_cat = $this->data->getCategorys('com_drinkcats');
							$food_cat = $this->data->getCategorys('com_foodcats');
							if(isset($this->item_user->sub_food)) $arr_foot_cat =json_decode($this->item_user->sub_food);
							//print_r($arr_foot_cat);
							for($i=0;$i<count($food_cat);$i++) {
							?> <div>
                            	<input <?php if(isset($this->item_user->sub_food)&&count($arr_foot_cat)>0&&in_array($food_cat[$i]->id,$arr_foot_cat)) echo 'checked="checked"';?> name="sub_food[]" type="checkbox" class="ck" value="<?php echo $food_cat[$i]->id;?>"/><?php echo $food_cat[$i]->title;?></div>
                            <?php
							}
							?>
                      
                    
                    
                  </div><!--.request-content-->

                  <div class="request-content">
                    <label>Andet mad:</label>
                    <div>
                      <input id="sub_food_other" name="sub_food_other" value="<?php if(isset($this->item_user)) echo $this->item_user->sub_food_other;?>"  type="text" class="tbox">
                    </div>
                  </div>

                  <div class="request-content">
                    <label>Ønsket drikkevare</label>
                   
                     	 <?php 
							
							$drink_cat = $this->data->getCategorys('com_drinkcats');
							if(isset($this->item_user)) $arr_drink_cat = json_decode($this->item_user->sub_drink);
							//print_r($arr_drink_cat);
							for($i=0;$i<count($drink_cat);$i++) {
							?>
                            	 <div><input <?php if(isset($this->item_user)&&count($arr_drink_cat)>0&&in_array($drink_cat[$i]->id,$arr_drink_cat)) echo 'checked="checked"';?>  name="sub_drink[]"  type="checkbox" class="ck" value="<?php echo $drink_cat[$i]->id;?>"/><?php echo $drink_cat[$i]->title;?></div>
                            <?php
							}
							?>
                  </div>

                  <div class="request-content">
                    <label>Andet drikke:</label>
                    <div>
                      <input maxlength="255" id="sub_drink_other" name="sub_drink_other" type="text" class="tbox" value="<?php if(isset($this->item_user)) echo $this->item_user->sub_drink_other;?>" >
                    </div><br><br>                   
                    <a href="#" onclick="jQuery('#allowsubmit').val(1);jQuery('#f-create-order').submit();" class="bntNext bnt01 mt15">Næste</a>
                  </div>
                </div><!--.catering-->

                <div class="rental-kok w564 noDisplay">
                  <h2>Indhent tilbud på Leje af Kok</h2>
                  <h3>Detaljer</h3>
                  <div>
                    <label>Antal timer</label>
                    <input maxlength="255" name="sub_room_time" id="sub_room_time" type="text" class="tbox" value="<?php if(isset($this->item_user->sub_room_time)) echo $this->item_user->sub_room_time;?>">
                  </div>
                  <div class="clear"></div>
                  <div class="ml-180">
                    <label>Specialitet</label>
                    <select name="sub_room_country" id="sub_room_country">
                      <?php 
							$specialitetcats = $this->data->getCategorys('com_specialitetcats');
							
							for($i=0;$i<count($specialitetcats);$i++) {
							?>
                            	<option <?php if (isset($this->item_user)&&$this->item_user->sub_room_country == $specialitetcats[$i]->id) echo 'selected="selected" ';?> value="<?php echo $specialitetcats[$i]->id;?>"><?php echo $specialitetcats[$i]->title;?></option>
                            <?php
							}
							?>
                    </select>
                  </div>
                  <div class="clear"></div>
                  <a href="#" onclick="jQuery('#allowsubmit').val(1);jQuery('#f-create-order').submit();" class="bntNext bnt01">Næste</a>
                </div><!--.rental-kok-->

                <div class="premises w564 noDisplay">
                  <h2>Indhent tilbud på Lokaler</h2>
                  <h3>Detaljer</h3>
                  <div>                    
                    <select id="sub_rent" name="sub_rent">
                      <?php 
							$rentcats = $this->data->getCategorys('com_lokalercats');
							
							for($i=0;$i<count($rentcats);$i++) {
							?>
                            	<option <?php if (isset($this->item_user)&&$this->item_user->sub_rent == $rentcats[$i]->id) echo 'selected="selected" ';?> value="<?php echo $rentcats[$i]->id;?>"><?php echo $rentcats[$i]->title;?></option>
                            <?php
							}
							?>
                    </select>
                  </div>
                  <div class="clear"></div>
                  <div class="ml-180">
                    <label>Beskrivelse af event:</label>
                    <textarea id="sub_rent_desc" name="sub_rent_desc"><?php if(isset($this->item_user)) echo $this->item_user->sub_rent_desc;?></textarea>
                  </div>
                  <div class="clear"></div>
                  <a href="#" onclick="jQuery('#allowsubmit').val(1);jQuery('#f-create-order').submit();" class="bntNext bnt01">Næste</a>
                  
                </div><!--.premises-->
      		
      </div>
      
                </fieldset>
            </form>
      	</div>
      <!--.f-create-Order--> 
      
      
      
      
      </div>
      <!--#edit-account-page--> 
    </div>
    <!--#main-right--> 
  </div>
  <!--#w-main--> 
</div>
<!--#main-->
<div class="clear"></div>
<div id="contact">
  <div id="w-contact">
    <div class="left-con">
      <div class="left-con-top"></div>
      <!--left-con-top-->
      <div class="left-con-mid">
        <div class="contact-con">
		<?php $article = JUtility::getArticle(17); ?>
          <h2><a href="#"><?php echo $article->title; ?></a></h2>
          <?php echo $article->introtext; ?>
        </div>
        <!--.contact-con-->
        <div class="contact-con contact-con2">
			<?php $article = JUtility::getArticle(18); ?>
			<h2><a href="#"><?php echo $article->title; ?></a></h2>
			<?php echo $article->introtext; ?>
        </div>
        <!--.contact-con--> 
      </div>
      <!--left-con-mid-->
      <div class="left-con-bottom"></div>
      <!--left-con-bottom--> 
    </div>
    <!--.left-con-->
    
    <div class="address">
		<?php $article = JUtility::getArticle(16); ?>
		<h2><?php echo $article->title; ?></h2>
		<?php echo $article->introtext; ?>
    </div>
    <!--address--> 
    
    <div class="contact-form">
		{module kontakt}
    </div><!--.contact-form-->
  </div>
  <!--w-contact--> 
</div>
<!--#contact-->
<div class="clear"></div>
<div id="copyright">
	<div id="w-copyright">
		{module footer}
	</div>
</div>
<!--#copyright-->
<?php                        	       
$input_name = JText::_( 'Indtast din begivenhed' );
$input_quantity = JText::_( 'Indtast din antal gæster' );
$input_address = JText::_( 'Indtast din addresse' );
$input_postcode = JText::_( 'Indtast din post nr' );
$input_city = JText::_( 'Indtast din by' );
$input_date = JText::_( 'Indtast din dato &amp; tidspunkt' );
$input_description = JText::_( 'Indtast din tilknyt kommentar' );
$input_agree = JText::_( 'Venligst accepterer vores handelsbetingelser' );
	
?>                        
 <script type="text/javascript">                   
jQuery(document).ready(function(jQuery) {
	jQuery.validator.addMethod('postalcode', function (value) { 
		if(value=='') return true;	
		return /^\d{4}$/.test(value); 
	   }, '');
		 
		jQuery("#f-create-order").validate(
			{
				errorPlacement: function(error, element) {			
			},
			invalidHandler: function(form, validator) {
			  var errors = validator.numberOfInvalids();
			if (errors) {
                //$('#alert').html(validator['errorList'][0]['message']);
				jQuery('#alert').html(validator['errorList'][0]['message']);
    			jQuery('#backoverlay').show();
    			jQuery('#show_popup').show();
            	jQuery('#f_focus').html(validator['errorList'][0]['element'].name);
				validator['errorList'][0]['element'].focus();
				
			  } else {
			  }
			},
			rules: {
				name:{
					required: true,
				},			
				quantity: {
					required: true,
					digits:true,
				},
				address:{
					required: true,
				},
				postcode:{
					required: true,
					digits: true,
					minlength: 4,
					maxlength: 4
				},
				city:{
					required: true,
				},
				datepicker2:{
					required: true,
				},
				description:{
					required: true,
				},
				agree:{
					required: true,
				},
			},
			messages: {
				name: "<?php echo $input_name; ?>",
				quantity: "<?php echo $input_quantity; ?>",
				address: "<?php echo $input_address; ?>",
				postcode: "<?php echo $input_postcode; ?>",
				city: "<?php echo $input_city; ?>",
				datepicker2: "<?php echo $input_date; ?>",
				description: "<?php echo $input_description; ?>",
				agree: "<?php echo $input_agree; ?>",
			}
			
			,
      		submitHandler: function(form) { 
				if(jQuery("#offer").val()=="14") { jQuery(".request-offer .catering").removeClass('noDisplay'); }
				if(jQuery("#offer").val()=="15") { jQuery(".request-offer .rental-kok").removeClass('noDisplay'); }
				if(jQuery("#offer").val()=="16") { jQuery(".request-offer .premises").removeClass('noDisplay'); }
				jQuery(".infohide").hide();
				if(jQuery("#allowsubmit").val()=='1') form.submit();
				
			}
		});
		
	});
</script>